Ext.define('AM.view.WeekProcedureView', {
		extend: 'Ext.grid.Panel',
		alias : 'widget.weekProcedureView',
		store : 'WeekProcedureStore',
		id:'weekProcedureView',
		columnLines:true,
		plugins: [{
            ptype: 'rowexpander',
            rowBodyTpl : new Ext.XTemplate(
                '<p><b>要求:</b> {jobRequirement}</p>'  
            )
        }],
		columns: [
			        { text: '序号', width:50,align:'center', xtype: 'rownumberer'},
			        { text: '名称', dataIndex: 'name', width:100,align:'center'},
			        { text: '开始时间', dataIndex: 'startdate', width:100,align:'center',xtype: 'datecolumn',   format:'Y-m-d'},
			        { text: '状态', dataIndex: 'state',  width:80,align:'center',renderer: function(value){
								 if (value === 1) {
										  return '<span style="color:purple;">未办理</span>'; 
								 }if (value ===2) {
								 	  return '<span style="color:green;">办理中</span>';
								 }if (value === 3) {
										return '<span style="color:red;">完成</span>';
								 }	
						}					 
			        },
			        { text: '要求', dataIndex: 'jobRequirement', width:100,align:'center'},
			        { text: '操作', dataIndex: 'id',width:210,align:'center',renderer : function(data, cell, record, rowIndex,columnIndex){			        	
			        	    var resultStr = "<div class='controlBtn'>" +     
                            "<a href='javascript:void("+record.get('id')+");'class='alarm_detail'onclick='banLi("+record.get('id')+")'>办理任务</a>&nbsp;&nbsp;&nbsp;&nbsp;" +     
                            "<a href='javascript:void("+record.get('id')+");' class='alarm_detail'onclick='wancheng("+record.get('id')+")'>完成任务</a>&nbsp;&nbsp;&nbsp;&nbsp;"+
                            "<a href='javascript:void("+record.get('id')+");' class='alarm_detail'onclick='shanchu("+record.get('id')+")'>删除任务</a>"
                            "</div>";     
         					return resultStr;  
			       		  }
         	    	}
			     ]

})
//办理工作
 function banLi(id){
   	  	Ext.Ajax.request({
				url : 'jobDetail_banli',
				success : function() {
//					Ext.MessageBox.alert("提示", "办理成功！");
					 Ext.getCmp('weekProcedureView').getStore().reload();						 
				},
				failure : function() {
					Ext.MessageBox.alert("提示", "项目正在办理中！");
				},
				params : {
						id:id	
					}
		});		
   
 }
 function shanchu(id){
   	  	Ext.Ajax.request({
				url : 'jobDetail_deleteWeekjob',
				success : function() {
					Ext.MessageBox.alert("提示", "删除成功！");
					 Ext.getCmp('weekProcedureView').getStore().reload();						 
				},
				failure : function() {
					Ext.MessageBox.alert("提示", "请刷新页面！");
				},
				params : {
						id:id	
					}
		});		
   
 }
   //完成工作
  function wancheng(id){
   	  	Ext.Ajax.request({
				url : 'jobDetail_wanchengWeekjob',
				success : function() {
					 Ext.getCmp('weekProcedureView').getStore().reload();						 
				},
				failure : function() {
					Ext.MessageBox.alert("提示", "项目还未办理！");
				},
				params : {
						id:id	
					}
		});	 
 	
 }